package main

import (
	"fmt"
	"log"
)

func f() int {
	return 10
}

func g(i int) int {
	return i * 2
}

func h(i int, s string) {
	fmt.Println(i, s)
}

func main() {

	// 赋值语句：交换
	a := 10
	b := 20
	a, b = b, a // exchange a and b

	// 空白标识(blank identify)
	x := 10
	_ = x // evaluate x but ignore it

	ifStat()
	forStat()

	// Label 语句
	goto Error
Error:
	log.Panic("error encountered")
}

func ifStat() int {

	y := 20
	z := 30
	if x := f(); x < y {
		return x
	} else if x > z {
		return z
	} else {
		return y
	}
}

func forStat() {
	a := 10
	b := 20

	// 单个条件的 For 语句
	for a < b {
		a++
	}

	for i := 0; i < 10; i++ {
		g(i)
	}

	var arr [10]string
	for i, s := range arr {
		// type of i is int
		// type of s is string
		// s == a[i]
		h(i, s)
	}
}
